import './assets/styles/main.scss'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import '@/framework/common/config'
import DateUtil from '@/framework/utils/date-util'
import { resetForm } from '@/framework/common/functions'


import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'
const pinia = createPinia()
const app = createApp(App)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(router)
app.use(pinia)
app.use(ElementPlus, {
  locale: zhCn
})

app.config.globalProperties.resetForm = resetForm

// 设置过滤器
app.config.globalProperties.$filters = {
  // 日期格式化
  date(value: any, format?: string) {
    if (!value) {
      return ''
    }
    format = format || 'yyyy-MM-dd'
    const date = DateUtil.toDate(value)
    return DateUtil.format(date, format)
  },

  // 时间格式化
  datetime(value: any, format?: string) {
    if (!value) {
      return ''
    }
    format = format || 'yyyy-MM-dd HH:mm:ss'
    const date = DateUtil.toDate(value)
    return DateUtil.format(date, format)
  }
}

app.mount('#app')
